const axios = require('axios');
const Router = require('koa-router') // 路由
const router = new Router()

router.post('/deepseek/chat', async (ctx) => {
    console.log(ctx.request.body);
    const message = ctx.request.body.content;
    const data = {
        model: 'deepseek-r1:1.5b',
        messages: [
            {
                role: 'user',
                content: message
            }
        ],
        stream: false
    }

    

    //跟 deepseek 模型进行通信
    const response = await axios.post("http://localhost:11434/api/chat", data)
    // console.log(response.data.message.content);
    
    ctx.body = {
        code: 200,
        content: response.data.message.content
        }
})

module.exports = router; 